<template>
  <el-container>
    <el-header height="220">
      <el-steps :active="curStep" simple>
        <el-step title="组卷配置" icon="el-icon-edit"></el-step>
        <el-step title="考试权限" icon="el-icon-lock"></el-step>
        <el-step title="补充配置" icon="el-icon-setting"></el-step>
      </el-steps>

      <el-button style="margin-top: 10px" v-show="curStep !== 1" @click="curStep--">上一步</el-button>

      <el-button style="float:right;margin-top: 10px" v-show="curStep !== 3" type="primary" @click="nextStepCheck">下一步
      </el-button>
      <el-button style="float:right;margin-top: 10px" v-show="curStep === 3" type="primary" @click="addExam">提交
      </el-button>
    </el-header>

    <el-main>
      <!--设置试题信息-->
      <el-card v-show="curStep === 1">
        <div>
          <div style="margin-bottom: 10px"><span style="font-size: medium ;font-weight: bold">试题列表</span>
            <span style="float: right;color: red;font-weight: bold">
            {{ '试卷总分：' + sumTotalScore }}</span>
          </div>
          <el-button type="primary" icon="el-icon-plus" size="small" @click="showAddDialog">添加试题</el-button>

          <el-button type="primary" icon="el-icon-circle-plus" size="small" @click="showRandomDialog">随机出题</el-button>
          <div style="float: right ;color: #409EFF ;font-size: small">
            <span>{{ ' 单选题：' + sumTotalSingle +' 个 | '}}</span>
            <span>{{ ' 多选题：' + sumTotalMultiple +' 个 | '}}</span>
            <span>{{ ' 判断题：' + sumTotalJudge +' 个 | '}}</span>
            <span>{{ ' 填空题：' + sumTotalComp +' 个 | '}}</span>
            <span>{{ ' 简答题：' + sumTotalShort +' 个'}}</span>
          </div>

          <el-table :data="addExamQuestion" border style="margin-top: 10px">

            <el-table-column
              type="index"
              label="序号"
              width="50">
            </el-table-column>

            <el-table-column label="题目内容" align="center" show-overflow-tooltip>
              <template slot-scope="scope">
                {{ scope.row.questionContent }}
              </template>
            </el-table-column>

            <el-table-column align="center"
                             label="题目类型" width="80">
              <template slot-scope="scope">
                <span v-if="scope.row.questionType === 1">单选题</span>
                <span v-else-if="scope.row.questionType === 2">多选题</span>
                <span v-else-if="scope.row.questionType === 3">判断题</span>
                <span v-else-if="scope.row.questionType === 4">简答题</span>
                <span v-else-if="scope.row.questionType === 5">填空题</span>
              </template>
            </el-table-column>

            <el-table-column label="单题分数" align="center" width="100">
              <template slot-scope="scope">
                <el-input v-model.number="scope.row.score" style="margin-left: 5px" type="number" min="1"
                          onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                          onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"></el-input>
              </template>
            </el-table-column>

            <el-table-column label="操作" width="80" align="center">
              <template slot-scope="scope">
                <el-button type="danger" icon="el-icon-delete" circle
                           @click="delQuestion(scope.row.questionId)"></el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-card>

      <!--设置考试权限-->
      <el-card v-show="curStep === 2">
        <el-radio-group v-model="examAuthority" size="medium">
          <el-radio :label="1" border>完全公开</el-radio>
          <el-radio :label="2" border>需要密码</el-radio>
        </el-radio-group>

        <el-alert style="margin-top: 15px"
                  :title="examAuthority === 1? '开放的，任何人都可以进行考试！' : '半开放的，知道密码的人员才可以考试！'"
                  type="warning">
        </el-alert>

        <el-input style="margin-top: 15px;width: 20%" v-model="examPassword" v-show="examAuthority === 2"
                  type="password" show-password placeholder="输入考试密码"></el-input>
        <br>
        <el-select style="margin-top: 10px"
          multiple clearable v-model="examInfo.examClass" placeholder="请选择考试班级">
          <el-option
            v-for="item in classInfo"
            :key="item.classId"
            :label="item.className"
            :value="item.classId">
          </el-option>
        </el-select>
      </el-card>

      <!--设置考试信息-->
      <el-card v-show="curStep === 3">

        <el-form :model="examInfo" :rules="examInfoRules" ref="examInfoForm" label-width="100px">

          <el-form-item label="考试名称" prop="examName">
            <el-input v-model="examInfo.examName"></el-input>
          </el-form-item>

          <el-form-item label="考试描述" prop="examDesc">
            <el-input v-model="examInfo.examDesc"></el-input>
          </el-form-item>

          <el-form-item label="总分数" prop="totalScore">
            <el-input-number :value="sumTotalScore" :disabled="true"></el-input-number>
          </el-form-item>

          <el-form-item label="及格分数" prop="passScore">
            <el-input-number v-model="examInfo.passScore" :min="1"></el-input-number>
          </el-form-item>

          <el-form-item label="考试时长(分钟)" prop="examDuration">
            <el-input-number v-model="examInfo.examDuration" :min="1"></el-input-number>
          </el-form-item>

          <el-form-item label="考试开始时间(空则不限时)" prop="startTime">
            <el-date-picker style="margin-left: 5px"
                            v-model="examInfo.startTime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            type="datetime" placeholder="考试开始时间">
            </el-date-picker>
          </el-form-item>

        </el-form>

      </el-card>
    </el-main>

    <el-dialog title="添加题目" :visible.sync="showQuestionDialog" width="80%" center>
      <el-row>
        <el-select @change="typeChange" clearable v-model="queryInfo.questionType" placeholder="请选择题目类型">
          <el-option
            v-for="item in questionType"
            :key="item.id"
            :label="item.name"
            :value="item.id">
          </el-option>
        </el-select>

        <el-select @change="bankChange" clearable v-model="queryInfo.questionBank" placeholder="请选择题库"
                   style="margin-left: 5px">
          <el-option
            v-for="item in allBank"
            :key="item.questionBank.bankId"
            :label="item.questionBank.bankName"
            :value="item.questionBank.bankName">
          </el-option>
        </el-select>

        <el-input v-model="queryInfo.questionContent" @blur="getQuestionInfo" placeholder="题目内容"
                  style="margin-left: 5px;width: 220px"
                  prefix-icon="el-icon-search"></el-input>
        <el-button type="primary" @click="addQuToFree" style="float: right">确认{{ selectedTable.length }}项</el-button>
      </el-row>

      <el-table
        ref="questionTable"
        highlight-current-row
        v-loading="loading"
        :border="true"
        :data="questionInfo"
        tooltip-effect="dark"
        style="width: 100%;margin-top: 25px;" @selection-change="handleTableSectionChange">

        <el-table-column align="center"
                         type="selection"
                         width="55">
        </el-table-column>

        <el-table-column align="center"
                         label="题目类型" width="80">
          <template slot-scope="scope">
            <span v-if="scope.row.quType === 1">单选题</span>
            <span v-else-if="scope.row.quType === 2">多选题</span>
            <span v-else-if="scope.row.quType === 3">判断题</span>
            <span v-else-if="scope.row.quType === 4">简答题</span>
            <span v-else-if="scope.row.quType === 5">填空题</span>
          </template>
        </el-table-column>

        <el-table-column align="center" label="题目内容" show-overflow-tooltip>
          <template slot-scope="scope">
            <span class="quContent">{{ scope.row.quContent }}</span>
          </template>
        </el-table-column>

        <el-table-column align="center"
                         label="难度" width="60">
          <template slot-scope="scope">
            <span v-if="scope.row.level === 1">简单</span>
            <span v-if="scope.row.level === 2">中等</span>
            <span v-if="scope.row.level === 3">困难</span>
          </template>
        </el-table-column>

        <el-table-column align="center"
                         prop="quBankName"
                         label="所属题库" width="200">
        </el-table-column>

        <el-table-column align="center"
                         prop="createPerson"
                         label="创建人" width="100">
        </el-table-column>

        <el-table-column align="center"
                         label="创建时间" width="180">
          <template slot-scope="scope">
            {{ scope.row.createTime }}
          </template>
        </el-table-column>


      </el-table>
      <!--分页-->
      <el-pagination style="margin-top: 25px"
                     @size-change="handleSizeChange"
                     @current-change="handleCurrentChange"
                     :current-page="queryInfo.pageNo"
                     :page-sizes="[10, 20, 30, 50]"
                     :page-size="queryInfo.pageSize"
                     layout="total, sizes, prev, pager, next, jumper"
                     :total="total">
      </el-pagination>
    </el-dialog>

    <el-dialog title="随机出题" :visible.sync="showRandomQuDialog" width="50%" center>
      <el-card>
        <el-form :model="randomQuForm" :rules="randomQuFormRules" ref="randomQuForm" label-width="100px">
          <el-form-item label="题目类型" prop="questionType">
            <el-select multiple clearable @change="quTypeChange" v-model="randomQuForm.questionType" placeholder="请选择题目类型">
              <el-option
                v-for="item in questionType"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>

          <el-form-item v-if="randomQuInputV.singleChoice" label="单选题数量" prop="singleChoice">
            <el-input type="number" min="1" v-model.number="randomQuForm.singleChoice" style="width: 205px"
                   onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"></el-input>
          </el-form-item>
          <el-form-item v-if="randomQuInputV.multipleChoice" label="多选题数量" prop="multipleChoice">
            <el-input type="number" min="1" v-model.number="randomQuForm.multipleChoice" style="width: 205px"
                   onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"></el-input>
          </el-form-item>
          <el-form-item v-if="randomQuInputV.judge" label="判断题数量" prop="judge">
            <el-input type="number" min="1" v-model.number="randomQuForm.judge" style="width: 205px"
                   onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"></el-input>
          </el-form-item>
          <el-form-item v-if="randomQuInputV.completion" label="填空题数量" prop="completion">
            <el-input type="number" min="1" v-model.number="randomQuForm.completion" style="width: 205px"
                   onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"></el-input>
          </el-form-item>
          <el-form-item v-if="randomQuInputV.shortAnswer" label="简答题数量" prop="shortAnswer">
            <el-input type="number" min="1" v-model.number="randomQuForm.shortAnswer" style="width: 205px"
                   onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                   onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"></el-input>
          </el-form-item>

          <el-form-item label="题库" prop="questionBank">
            <el-select multiple clearable v-model="randomQuForm.questionBank" placeholder="请选择题库">
              <el-option
                v-for="item in allBank"
                :key="item.questionBank.bankId"
                :label="item.questionBank.bankName"
                :value="item.questionBank.bankId">
              </el-option>
            </el-select>
          </el-form-item>

        </el-form>
      </el-card>
      <div style="margin-bottom: 30px ;margin-top: 10px;">
        <el-button type="primary" @click="randomAddQuToFree" style="float: right">确认</el-button>
        <el-button @click="resetRandomdialog()" style="float: right; margin-right: 20px">重置</el-button>
      </div>
    </el-dialog>

  </el-container>
</template>

<script>
export default {
  name: 'AddExam',
  data() {
    return {
      //查询题目的参数
      queryInfo: {
        //题目类型下拉款所选的内容
        'questionType': '',
        'questionBank': '',
        'questionContent': '',
        'pageNo': 1,
        'pageSize': 10
      },
      //随机出题的参数
      randomQuForm: {
        'questionType': '',
        'questionBank': '',
        'singleChoice': 0,
        'multipleChoice':0,
        'judge':0,
        'completion':0,
        'shortAnswer':0,
      },
      //随机出题表单的验证规则
      randomQuFormRules: {
        questionType: [
          {
            required: true,
            message: '请选择问题类型',
            trigger: 'blur'
          }
        ],
        questionBank: [
          {
            required: true,
            message: '请选择题库',
            trigger: 'blur'
          }
        ],
        singleChoice: [
          {
            required: true,
            message: '请填写数量',
            trigger: 'blur'
          }
        ],
        multipleChoice: [
          {
            required: true,
            message: '请填写数量',
            trigger: 'blur'
          }
        ],
        judge: [
          {
            required: true,
            message: '请填写数量',
            trigger: 'blur'
          }
        ],
        completion: [
          {
            required: true,
            message: '请填写数量',
            trigger: 'blur'
          }
        ],
        shortAnswer: [
          {
            required: true,
            message: '请填写数量',
            trigger: 'blur'
          }
        ],
      },
      //题目类型
      questionType: [
        {
          id: 1,
          name: '单选题',
        },
        {
          id: 2,
          name: '多选题',
        },
        {
          id: 3,
          name: '判断题',
        },
        {
          id: 4,
          name: '简答题',
        },
        {
          id: 5,
          name: '填空题',
        },
      ],
      //当前的步骤
      curStep: 1,
      addExamQuestion: [],
      //所有题库信息
      allBank: [],
      //班级信息
      classInfo: [],
      //所有题目的对话框
      showQuestionDialog: false,
      //对话框中题目表格的加载
      loading: true,
      //随机出题表单框
      showRandomQuDialog: false,
      //随机出题题目类型参数输入框显示控制
      randomQuInputV:{
        'singleChoice':false,
        'multipleChoice':false,
        'judge':false,
        'completion':false,
        'shortAnswer':false,
      },
      //所有题目的信息
      questionInfo: [],
      //所有题目的对话框中表格被选中
      selectedTable: [],
      //所有题目总数
      total: 0,
      //考试权限(1公开, 2密码)
      examAuthority: 1,
      //考试密码(权限为2时的密码)
      examPassword: '',
      //补充的考试信息
      examInfo: {
        'examId': '',
        'examDesc': '',
        'passScore': 0,
        'examDuration': '',
        'startTime': '',
        'endTime': '',
        'examClass':''
      },
      //补充的考试信息的表单验证
      examInfoRules: {
        examName: [
          {
            required: true,
            message: '请输入考试名称',
            trigger: 'blur'
          }
        ],
        passScore: [
          {
            required: true,
            message: '请输入通过分数',
            trigger: 'blur'
          }
        ],
        examDuration: [
          {
            required: true,
            message: '请输入考试时长',
            trigger: 'blur'
          }
        ],
      },
    }
  },
  props: ['tagInfo'],
  created() {
    //一创建就改变头部的面包屑
    this.$emit('giveChildChangeBreakInfo', '添加考试', '添加考试')
    this.createTagsInParent()
    this.getBankInfo()
    this.getClassInfo()
  },
  methods: {
    //向父组件中添加头部的tags标签
    createTagsInParent() {
      let flag = false
      this.tagInfo.map(item => {
        //如果tags全部符合
        if (item.name === '添加考试' && item.url === this.$route.path) {
          flag = true
        } else if (item.name === '添加考试' && item.url !== this.$route.path) {
          this.$emit('updateTagInfo', '添加考试', this.$route.path)
          flag = true
        }
      })
      if (!flag) this.$emit('giveChildAddTag', '添加考试', this.$route.path)
    },
    //获取所有的题库信息
    getBankInfo() {
      this.$http.get(this.API.getBankHaveQuestionSumByType, {
        params: {
          'pageNo': 1,
          'pageSize': 9999
        }
      }).then((resp) => {
        if (resp.data.code === 200) {
          this.allBank = resp.data.data.bankHaveQuestionSums
        } else {
          this.$notify({
            title: 'Tips',
            message: resp.data.message,
            type: 'error',
            duration: 2000
          })
        }
      })
    },
    //添加试题
    showAddDialog() {
      this.showQuestionDialog = true
      this.getQuestionInfo()
    },
    //随机出题
    showRandomDialog() {
      this.resetRandomdialog()
      this.showRandomQuDialog = true
    },
    resetRandomdialog(){
      this.randomQuForm.questionType = ''
      this.randomQuForm.questionBank = ''
      this.randomQuForm.singleChoice = 0
      this.randomQuForm.multipleChoice = 0
      this.randomQuForm.judge = 0
      this.randomQuForm.completion = 0
      this.randomQuForm.shortAnswer = 0
      for(var item in this.randomQuInputV){
        this.randomQuInputV[item] = false
      }
    },
    //删除试题
    delQuestion(questionId) {
      this.addExamQuestion.forEach((item, index) => {
        if (item.questionId === questionId) this.addExamQuestion.splice(index, 1)
      })
    },
    //随机出题题目类型变化
    quTypeChange(){
      for(var item in this.randomQuInputV){
        this.randomQuInputV[item] = false
      }
      this.randomQuForm.questionType.forEach((item, index) =>{
        if(item == 1){
          this.randomQuForm.singleChoice = 1
          this.randomQuInputV.singleChoice = true
        }else if(item == 2){
          this.randomQuForm.multipleChoice = 1
          this.randomQuInputV.multipleChoice = true
        }else if(item == 3){
          this.randomQuForm.judge = 1
          this.randomQuInputV.judge = true
        }else if(item == 4){
          this.randomQuForm.completion = 1
          this.randomQuInputV.completion = true
        }else if(item == 5){
          this.randomQuForm.shortAnswer = 1
          this.randomQuInputV.shortAnswer = true
        }
      })
    },
    //题目类型变化
    typeChange(val) {
      this.queryInfo.questionType = val
      this.getQuestionInfo()
    },
    //题库变化
    bankChange(val) {
      this.queryInfo.questionBank = val
      this.getQuestionInfo()
    },
    //获取题目信息
    getQuestionInfo() {
      this.$http.get(this.API.getQuestion, {params: this.queryInfo}).then((resp) => {
        if (resp.data.code === 200) {
          this.questionInfo = resp.data.data.questions;
          this.total = resp.data.data.total;
          this.loading = false
        } else {
          this.$notify({
            title: 'Tips',
            message: '获取题库信息失败',
            type: 'error',
            duration: 2000
          })
        }
      })
    },
    //处理表格被选中
    handleTableSectionChange(val) {
      this.selectedTable = val
    },
    //分页页面大小改变
    handleSizeChange(val) {
      this.queryInfo.pageSize = val
      this.getQuestionInfo()
    },
    //分页插件的页数
    handleCurrentChange(val) {
      this.queryInfo.pageNo = val
      this.getQuestionInfo()
    },
    //选中的题目添加进去
    addQuToFree() {
      this.selectedTable.forEach(item => {
        if (!this.addExamQuestion.some(i2 => {
          return i2.questionId === item.id
        })) {//不存在有当前题目
          this.addExamQuestion.push({
            'questionId': item.id,
            'questionContent': item.quContent,
            'questionType': item.quType,
            'score': 1
          })
        }
      })
      this.showQuestionDialog = false
    },
    randomAddQuToFree(){
      this.$refs['randomQuForm'].validate((valid) => {
        if (valid) {
          //多选框数据处理
          let s = []
          for(var i = 0; i < this.randomQuForm.questionType.length; i++) {
            s.push(this.randomQuForm.questionType[i])
          }
          this.randomQuForm.questionType = s.join()
          s = []
          for(var j = 0; j < this.randomQuForm.questionBank.length; j++) {
            s.push(this.randomQuForm.questionBank[j])
          }
          this.randomQuForm.questionBank = s.join()
          this.$http.get(this.API.getQuRandom, { params: this.randomQuForm }).then((resp) => {
            if (resp.data.code === 200) {
              this.selectedTable = resp.data.data.questions
              this.addQuToFree()
              this.loading = false
              this.$notify({
                'type': 'success',
                'title': 'Tips',
                'message': '随机添加题目成功',
                'duration': 2000
              })
            } else {
              this.$notify({
                title: 'Tips',
                message: '获取题库信息失败',
                type: 'error',
                duration: 2000
              })
            }
            this.showRandomQuDialog = false
          })
        } else {
          this.$message.error('请检查表单填写是否符合规则')
          return false
        }
      })
    },
    //添加考试
    addExam() {
      this.$refs['examInfoForm'].validate((valid) => {
        if (valid && this.addExamQuestion.length !== 0) {
          //构造数据对象(考试信息)
          let exam = this.examInfo
          exam.totalScore = this.sumTotalScore
          exam.status = 1
          //权限id设置
          exam.type = this.examAuthority
          if(exam.type === 2){
            exam.password = this.examPassword
          }
          //班级多选框数据处理
          let s = []
          for(var i = 0; i < this.examInfo.examClass.length; i++) {
            s.push(this.examInfo.examClass[i])
          }
          exam.examClass = s.join()
          //题目id数组
          let questionIds = []
          //题目成绩数组
          let scores = []
          this.addExamQuestion.forEach(item => {
            questionIds.push(item.questionId)
            scores.push(item.score)
          })
          exam.questionIds = questionIds.join(',')
          exam.scores = scores.join(',')
          console.log(exam)
          this.$http.post(this.API.addExamByQuestionList, exam).then((resp) => {
            if (resp.data.code === 200) this.$router.push('/examManage')
          })
        } else {
          this.$message.error('请检查考试规则设置是否完整')
          return false
        }
      })
    },
    //获取班级信息
    getClassInfo() {
      this.$http.get(this.API.getClassInfo, { params: this.queryInfo }).then((resp) => {
        if (resp.data.code === 200) {
          this.classInfo = resp.data.data.classes;
        } else {
          this.$notify({
            title: 'Tips',
            message: '获取信息失败',
            type: 'error',
            duration: 2000
          })
        }
      })
    },
    //下一步按钮规则校验
    nextStepCheck(){
      if(this.curStep==1){
        if(isNaN(this.sumTotalScore)||this.sumTotalScore==0){
          this.$notify({
            title: 'Tips',
            message: '请检查单题分数是否填写完整或添加试题',
            type: 'error',
            duration: 3000
          })
          return false
        }
      }else if(this.curStep==2){
        if (this.examAuthority === 2) {//考试密码
          if (this.examPassword === '') {// 当前用户选择了需要密码权限,但是密码为空
            this.$notify({
              title: 'Tips',
              message: '当前权限为需要密码,但是密码为空',
              type: 'error',
              duration: 2000
            })
            return false;
          }
        }
        if(this.examInfo.examClass == ''){
          this.$message.error('请选择考试班级')
          return false;
        }
      }
      this.curStep++
    }
  },
  computed: {
    //计算总分
    sumTotalScore() {
      let score = 0
      var re = /^[1-9]+[0-9]*]*$/; //判断字符串是否为正整数
      this.addExamQuestion.forEach(item => {
        if(!re.test(item.score)){
          this.$message.error('单题分数不能为空!')
        }
          score += parseInt(item.score)
      })
      return score
    },
    sumTotalMultiple() {
      let sum = 0
      this.addExamQuestion.forEach(item => {
        if(item.questionType==2){
          sum++
        }
      })
      return sum
    },
    sumTotalJudge() {
      let sum = 0
      this.addExamQuestion.forEach(item => {
        if(item.questionType==3){
          sum++
        }
      })
      return sum
    },
    sumTotalShort() {
      let sum = 0
      this.addExamQuestion.forEach(item => {
        if(item.questionType==4){
          sum++
        }
      })
      return sum
    },
    sumTotalComp() {
      let sum = 0
      this.addExamQuestion.forEach(item => {
        if(item.questionType==5){
          sum++
        }
      })
      return sum
    },
    sumTotalSingle() {
      let sum = 0
      this.addExamQuestion.forEach(item => {
        if(item.questionType==1){
          sum++
        }
      })
      return sum
    }
  }
}
</script>

<style scoped lang="scss">
.el-container {
  width: 100%;
  height: 100%;
}

.el-container {
  animation: leftMoveIn .7s ease-in;
}

@keyframes leftMoveIn {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0%);
    opacity: 1;
  }
}


/deep/ .el-table thead {
  color: rgb(85, 85, 85) !important;
}

/*表格的头部样式*/
/deep/ .has-gutter tr th {
  background: rgb(242, 243, 244);
  color: rgb(85, 85, 85);
  font-weight: bold;
  line-height: 32px;
}

.el-table {
  box-shadow: 0 0 1px 1px gainsboro;
}
</style>
